/**
 * Delta X Firmware
 * Copyright (c) 2020 DeltaXFirmware [https://github.com/deltaxrobot/Delta-X-Firmware]
 *
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include "Constants.h"

void Constants::init() {
    /** 初始化Delta机器参数 */
    RD_F = (float) DEFAULT_RD_F;
    RD_E = (float) DEFAULT_RD_E;
    RD_RF = (float) DEFAULT_RD_RF;
    RD_RE = (float) DEFAULT_RD_RE;

    RD_W = (float) DEFAULT_RD_W;
    RD_U = (float) DEFAULT_RD_U;
    RD_V = (float) DEFAULT_RD_V;

    /**
     * 在Geometry中定义了运动范围，有两种 根据预编译宏设置编译参数
     */
    MOVING_AREA_X = (float) DEFAULT_MOVING_AREA_X; // 170mm
    MOVING_AREA_Y = (float) DEFAULT_MOVING_AREA_Y; // 170mm
    MOVING_AREA_Z = (float) DEFAULT_MOVING_AREA_Z; // 420mm

    MOVING_AREA_LARGEST_DIAMETER = (float) DEFAULT_MOVING_AREA_LARGEST_DIAMETER; // 运动的最大直径 170mm

    /**
     * 定义的默认速度和加速度
     */
    Velocity = (float) DEFAULT_VELOCITY;            // 300mm/s
    Acceleration = (float) DEFAULT_ACCELERATION;    // 2000mm^2/s, 即 0.2m^2/s

    /**
     * 回原点的速度
     */
    MovingHomeSpeed = (float) DEFAULT_MOVING_HOME_SPEED; // deg/s

    /**
     * 开始速度
     */
    BeginEndVelocity = (float) DEFAULT_BEGIN_VELOCITY; // 12mm/s

    /**
     * 进入/退出的速度
     */
    EntryVelocity = (float) DEFAULT_ENTRY_VELOCITY; // 12mm/s
    ExitVelocity = (float) DEFAULT_EXIT_VELOCITY; // 12mm/s

    /**
     * 以绝对坐标移动
     */
    IsMoveWithTheAbsoluteCoordinates = true;
    /**
     * 是否被执行的G码
     */
    IsExecutedGcode = false;

    End_Effector = USE_VACUUM; // 末端执行器为真空泵

    MMPerLinearSegment = (float) MM_PER_LINEAR_SEGMENT;

    MMPerArcSegment = (float) MM_PER_ARC_SEGMENT;
}

void Constants::ResetData() {
    init();
}


Constants Data;

